package com.hengtongxing.hejiayun_employee.mine.model;


import com.hengtongxing.hejiayun_employee.appconst.MethodType;
import com.hengtongxing.hejiayun_employee.appconst.URLConst;
import com.hengtongxing.hejiayun_employee.base.DataCallBack;
import com.hengtongxing.hejiayun_employee.bean.AddressListBean;
import com.hengtongxing.hejiayun_employee.bean.BaseResponseBean;
import com.hengtongxing.hejiayun_employee.bean.DirectorListBean;
import com.hengtongxing.hejiayun_employee.bean.ExchangeDetailsBean;
import com.hengtongxing.hejiayun_employee.bean.ExchangeListBean;
import com.hengtongxing.hejiayun_employee.bean.MyPlanListBean;
import com.hengtongxing.hejiayun_employee.bean.OrderDetailsBean;
import com.hengtongxing.hejiayun_employee.bean.OrderListBean;
import com.hengtongxing.hejiayun_employee.bean.PlanConfigListBean;
import com.hengtongxing.hejiayun_employee.bean.PosterListBean;
import com.hengtongxing.hejiayun_employee.bean.RechargeConfigBean;
import com.hengtongxing.hejiayun_employee.bean.SginConfigBean;
import com.hengtongxing.hejiayun_employee.bean.SginTaskBean;
import com.hengtongxing.hejiayun_employee.bean.SignInDayBean;
import com.hengtongxing.hejiayun_employee.bean.SignIsBean;
import com.hengtongxing.hejiayun_employee.bean.UserInfoBean;
import com.hengtongxing.hejiayun_employee.retorfit_manager.ResponseObserver;
import com.hengtongxing.hejiayun_employee.retorfit_manager.RetrofitHelper;
import com.hengtongxing.hejiayun_employee.utils.ToastUtil;

import java.util.HashMap;
import java.util.Map;

public class MineModelImpl implements IMineModel {
    @Override
    public void requestMine(DataCallBack<UserInfoBean> callBack) {
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.ME, null, new ResponseObserver<UserInfoBean>() {
            @Override
            public void onSuccessful(UserInfoBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(UserInfoBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestFeedBack(String content, DataCallBack<BaseResponseBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        params.put("content", content);
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.OpinionAdd, params, new ResponseObserver<BaseResponseBean>() {
            @Override
            public void onSuccessful(BaseResponseBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(BaseResponseBean bean, String msg, String code) {
                callBack.onFailed(msg, code);
            }
        });
    }

    @Override
    public void requestLoginOut(String id, DataCallBack<BaseResponseBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        params.put("id", id);
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.LOGINOUT, params, new ResponseObserver<BaseResponseBean>() {
            @Override
            public void onSuccessful(BaseResponseBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(BaseResponseBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestLoginOutAccount(DataCallBack<BaseResponseBean> callBack) {
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.LOGINOUTACCOUNT, null, new ResponseObserver<BaseResponseBean>() {
            @Override
            public void onSuccessful(BaseResponseBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(BaseResponseBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestUnBindDeviceId(String client_no, DataCallBack<BaseResponseBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        params.put("client_no", client_no == null ? "" : client_no);
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.unBindDeviceId, params, new ResponseObserver<BaseResponseBean>() {
            @Override
            public void onSuccessful(BaseResponseBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(BaseResponseBean bean, String msg, String code) {
                callBack.onFailed(msg, code);
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestAddressDelete(String id, DataCallBack<BaseResponseBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        params.put("id", id);
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.AgentAddressDelete, params, new ResponseObserver<BaseResponseBean>() {
            @Override
            public void onSuccessful(BaseResponseBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(BaseResponseBean bean, String msg, String code) {
                callBack.onFailed(msg, code);
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestAddressAdd(String name, String mobile, String province, String city, String area, String address, DataCallBack<BaseResponseBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        params.put("name", name);
        params.put("mobile", mobile);
        params.put("province", province);
        params.put("city", city);
        params.put("area", area);
        params.put("address", address);
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.AgentAddressAdd, params, new ResponseObserver<BaseResponseBean>() {
            @Override
            public void onSuccessful(BaseResponseBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(BaseResponseBean bean, String msg, String code) {
                callBack.onFailed(msg, code);
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestAddressEdit(String id, String name, String mobile, String province, String city, String area, String address, DataCallBack<BaseResponseBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        params.put("id", id);
        params.put("name", name);
        params.put("mobile", mobile);
        params.put("province", province);
        params.put("city", city);
        params.put("area", area);
        params.put("address", address);
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.AgentAddressUpdate, params, new ResponseObserver<BaseResponseBean>() {
            @Override
            public void onSuccessful(BaseResponseBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(BaseResponseBean bean, String msg, String code) {
                callBack.onFailed(msg, code);
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestAddressIndex(int page, DataCallBack<AddressListBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        params.put("page", page);
        params.put("limit", -1);
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.AgentAddressIndex, params, new ResponseObserver<AddressListBean>() {
            @Override
            public void onSuccessful(AddressListBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(AddressListBean bean, String msg, String code) {
                callBack.onFailed(msg, code);
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestMyOrderData(int page, String select_type, String order_status, DataCallBack<OrderListBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        params.put("page", page);
        params.put("limit", 10);
        params.put("select_type", select_type);
        params.put("order_status", order_status);
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.AgentOrderIndex, params, new ResponseObserver<OrderListBean>() {
            @Override
            public void onSuccessful(OrderListBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(OrderListBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestOrderShow(String id, String select_type, DataCallBack<OrderDetailsBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        params.put("id", id);
        params.put("select_type", select_type);
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.AgentOrderShow, params, new ResponseObserver<OrderDetailsBean>() {
            @Override
            public void onSuccessful(OrderDetailsBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(OrderDetailsBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestExchangeOrderShow(String id, DataCallBack<ExchangeDetailsBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        params.put("id", id);
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.AgentExchangeDeviceShow, params, new ResponseObserver<ExchangeDetailsBean>() {
            @Override
            public void onSuccessful(ExchangeDetailsBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(ExchangeDetailsBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestAgentExchangeDeviceIndex(int page, String status, DataCallBack<ExchangeListBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        params.put("page", page);
        params.put("limit", 20);
        params.put("status", status);
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.AgentExchangeDeviceIndex, params, new ResponseObserver<ExchangeListBean>() {
            @Override
            public void onSuccessful(ExchangeListBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(ExchangeListBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestAgentTurnParent(String id, DataCallBack<BaseResponseBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        params.put("id", id);
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.orderTurnParent, params, new ResponseObserver<BaseResponseBean>() {
            @Override
            public void onSuccessful(BaseResponseBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(BaseResponseBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestAgentDirector(int page, DataCallBack<DirectorListBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        params.put("page", page);
        params.put("limit", 20);
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.director, params, new ResponseObserver<DirectorListBean>() {
            @Override
            public void onSuccessful(DirectorListBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(DirectorListBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestSignAdd(DataCallBack<BaseResponseBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.SignAdd, params, new ResponseObserver<BaseResponseBean>() {
            @Override
            public void onSuccessful(BaseResponseBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(BaseResponseBean bean, String msg, String code) {
                callBack.onFailed(msg, code);
            }
        });
    }

    @Override
    public void requestSignRowSignDay(DataCallBack<SignInDayBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.SignRowSignDay, params, new ResponseObserver<SignInDayBean>() {
            @Override
            public void onSuccessful(SignInDayBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(SignInDayBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestIsSign(DataCallBack<SignIsBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.getIsSign, params, new ResponseObserver<SignIsBean>() {
            @Override
            public void onSuccessful(SignIsBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(SignIsBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestPlanConfig(DataCallBack<PlanConfigListBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.PlanConfig, params, new ResponseObserver<PlanConfigListBean>() {
            @Override
            public void onSuccessful(PlanConfigListBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(PlanConfigListBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestMyPlanList(int page, DataCallBack<MyPlanListBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        params.put("page", page);
        params.put("limit", 20);
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.AgentPlanIndex, params, new ResponseObserver<MyPlanListBean>() {
            @Override
            public void onSuccessful(MyPlanListBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(MyPlanListBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestPlanCreate(String plan_id, String amount, DataCallBack<BaseResponseBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        params.put("plan_id", plan_id);
        params.put("amount", amount);
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.PlanCreate, params, new ResponseObserver<BaseResponseBean>() {
            @Override
            public void onSuccessful(BaseResponseBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(BaseResponseBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestPlanApply(String agent_plan_id, DataCallBack<BaseResponseBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        params.put("agent_plan_id", agent_plan_id);
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.PlanApply, params, new ResponseObserver<BaseResponseBean>() {
            @Override
            public void onSuccessful(BaseResponseBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(BaseResponseBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestPosterIndex(DataCallBack<PosterListBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.PosterIndex, params, new ResponseObserver<PosterListBean>() {
            @Override
            public void onSuccessful(PosterListBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(PosterListBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestRechargeConfigIndex(DataCallBack<RechargeConfigBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.RechargeConfigIndex, params, new ResponseObserver<RechargeConfigBean>() {
            @Override
            public void onSuccessful(RechargeConfigBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(RechargeConfigBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestSignConfigIndex(DataCallBack<SginConfigBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.SignConfigIndex, params, new ResponseObserver<SginConfigBean>() {
            @Override
            public void onSuccessful(SginConfigBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(SginConfigBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestSignTaskIndex(DataCallBack<SginTaskBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.SignTaskIndex, params, new ResponseObserver<SginTaskBean>() {
            @Override
            public void onSuccessful(SginTaskBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(SginTaskBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }

    @Override
    public void requestTaskWXTask(DataCallBack<BaseResponseBean> callBack) {
        Map<String, Object> params = new HashMap<>();
        RetrofitHelper.getInstance().request(MethodType.POST, URLConst.TaskwxTask, params, new ResponseObserver<BaseResponseBean>() {
            @Override
            public void onSuccessful(BaseResponseBean bean, String msg) {
                callBack.onSuccessful(bean);
            }

            @Override
            public void onFailure(BaseResponseBean bean, String msg, String code) {
                ToastUtil.showShort(msg);
            }
        });
    }
}
